package cn.t.web.sku;

import cn.t.core.mode.PageInfoDTO;
import cn.t.core.mode.PageQueryDTO;
import cn.t.facade.sku.CategoryFacade;
import cn.t.request.CategoryReq;
import cn.t.request.CreateCategoryReq;
import cn.t.vo.sku.CategoryVO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 商品类别服务入口
 *
 * @author s
 * @since 2024-06-17
 */
@Slf4j
@RestController
@RequestMapping("category")
// "商品类别服务")
@AllArgsConstructor
public class CategoryController {

    @Autowired
    protected CategoryFacade facade;

    /**
     * 商品类别分页查询接口
     */
    @PostMapping(value = "/page")
    public PageInfoDTO<CategoryVO> page(@RequestBody PageQueryDTO<CategoryReq> req) {return facade.findCategoryByPage(req);}

    /**
     * 新增商品类别
     */
    @PostMapping("/add")
    public Boolean add(@Validated @RequestBody CreateCategoryReq req) {return facade.add(req);}

    /**
     * 编辑商品类别
     */
    @PostMapping("/update")
    public Boolean update(@Validated @RequestBody CreateCategoryReq req) {return facade.update(req);}

    /**
     * 删除商品类别
     */
    @PostMapping("/delete/{id}")
    public Boolean delete(@PathVariable Long id) {return facade.delete(id);}
}

